package me.dengfengdecao.demo.component;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * Spring Boot应用程序在启动后，会遍历CommandLineRunner接口的实例并运行它们的run方法。
 * 也可以利用@Order注解（或者实现Order接口）来规定所有CommandLineRunner实例的运行顺序,
 * 值越小优先级越高
 * Created by dengfengdecao on 16/9/27.
 */
@Component
@Order(1)
public class MyStartupRunner1 implements CommandLineRunner {

    public static final Logger log = LoggerFactory.getLogger(MyStartupRunner1.class);

    // args 是从main函数传过来的
    @Override
    public void run(String... args) throws Exception {
        log.debug("run: 服务启动执行，执行加载数据等操作");
    }
}
